<?php
class Person_Model extends CI_Model {
	public function __construct(){
		parent:: __construct();
	}

	public function get_name_country($countryId){
		$sql = $this->db->select('country')->get_where('regions', array('id' =>$countryId));
		$row = $sql->row();
		return $row->country;	
	}

	public function get_name_state($countryId){
		$sql = $this->db->select('name')->get_where('subregions', array('id' =>$countryId));
		$row = $sql->row();
		return $row->name;	
	}

	public function get_photo_person($personId) {
		$sql = $this->db->select('photo')->get_where('photo_person', array('person_id' => $personId))->row();
		if($sql->photo !== null) {
			return $sql->photo;
		} else {
			return null;
		}
	}

	public function get_person($id){
		$sql = $this->db->get_where('person', array('id' => $id))->row_array();
		return $sql;
	}
}